//
//  KSMainViewController.m
//  KSReader
//
//  Created by kennysun on 2016/12/23.
//  Copyright © 2016年 Kennysun. All rights reserved.
//

#import "KSMainViewController.h"
#import "LSYReadViewController.h"
#import "LSYReadPageViewController.h"
#import "LSYReadUtilites.h"
#import "LSYReadModel.h"

@interface KSMainViewController ()

@end

@implementation KSMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"书架";
    
    UIImageView *bgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"main_bg.png"]];
    bgView.frame = CGRectMake(0, 65, self.view.frame.size.width, self.view.frame.size.height - 115);
    [self.view addSubview:bgView];
    
    LSYReadPageViewController *pageView = [[LSYReadPageViewController alloc] init];
    NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"qingyunzhi"withExtension:@"txt"];
    pageView.resourceURL = fileURL;    //文件位置
    
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        
        pageView.model = [LSYReadModel getLocalModelWithURL:fileURL];
        
        dispatch_async(dispatch_get_main_queue(), ^{
            [self presentViewController:pageView animated:YES completion:nil];
        });
    });
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
